import type {
  FeedbackClearOperationType,
  FeedbackTagType,
  GreasyForkBaseUserType,
  ResolutionStatusType,
  ScriptClearOperationType,
  ScriptFeedbackActionType,
  ScriptStatusActionType,
} from '../../module/storage_process/types'
import { SYMBOLS } from '../../../../../../../../../types/interfaces'
import {
  GreasyForkFeedbackUserType,
  GreasyForkScriptUserType,
  GreasyForkUserType,
} from '../../module/storage_process/types'

export interface TagLabel {
  value: string // 标签值
  label: string // 显示文本
  icon: string // 图标符号
  bgColor: string // 背景颜色
  textColor: string // 文字颜色
  shouldGenerateStyle: boolean // 是否生成样式
  mutualExclusionId?: string // 互斥标签ID
}

// 标签类型 - 脚本
export type ScriptTagLabelsType = {
  [key in GreasyForkBaseUserType | GreasyForkScriptUserType | ScriptFeedbackActionType | ScriptStatusActionType | ScriptClearOperationType]: TagLabel;
}
// 标签类型 - 反馈
export type FeedbackTagLabelsType = {
  [key in GreasyForkUserType | FeedbackTagType | ResolutionStatusType | FeedbackClearOperationType ]: TagLabel;
}

// 用户标签类型
export type UserTagLabelsType = {
  [key in GreasyForkUserType]: TagLabel;
}

export type ScriptUserTagLabelsType = {
  [key in GreasyForkScriptUserType]: TagLabel;
}

export type FeedbackUserTagLabelsType = {
  [key in GreasyForkFeedbackUserType]: TagLabel;
}

export type BASEUserTagLabelsType = {
  [key in GreasyForkBaseUserType]: TagLabel;
}

// 用户标签 - 脚本
export const SCRIPTS_USER_TAG_LABELS: ScriptUserTagLabelsType = {
  [GreasyForkScriptUserType.SuperCreator]: {
    value: GreasyForkScriptUserType.SuperCreator,
    label: '脚本大神',
    icon: SYMBOLS.USER.ADMIN,
    bgColor: 'linear-gradient(135deg, #FFD700 0%, #FFA500 100%)',
    textColor: '#000000',
    shouldGenerateStyle: false,
  },
}
// 用户标签 - 反馈
export const FEEDBACK_USER_TAG_LABELS: FeedbackUserTagLabelsType = {
  [GreasyForkFeedbackUserType.FeedbackProvider]: {
    value: GreasyForkUserType.FeedbackProvider,
    label: '反馈达人',
    icon: SYMBOLS.OTHERS.COMMENT,
    bgColor: 'linear-gradient(135deg, #00B0FF 0%, #40C4FF 100%)',
    textColor: '#FFFFFF',
    shouldGenerateStyle: false,
  },
}
// 用户标签 - 基础
export const BASE_USER_TAG_LABELS: BASEUserTagLabelsType = {
  [GreasyForkUserType.ActiveUser]: {
    value: GreasyForkUserType.ActiveUser,
    label: '活跃用户',
    icon: '⚡',
    bgColor: 'linear-gradient(135deg, #00E676 0%, #76FF03 100%)',
    textColor: '#000000',
    shouldGenerateStyle: false,
  },
  [GreasyForkUserType.LoyalFan]: {
    value: GreasyForkUserType.LoyalFan,
    label: '铁杆粉丝',
    icon: SYMBOLS.EMOTIONS.ADORATION,
    bgColor: 'linear-gradient(135deg, #D500F9 0%, #FF4081 100%)',
    textColor: '#FFFFFF',
    shouldGenerateStyle: false,
  },
  [GreasyForkUserType.Blacklisted]: {
    value: GreasyForkUserType.Blacklisted,
    label: '黑名单',
    icon: SYMBOLS.UI.BLOCK_ALERT,
    bgColor: 'linear-gradient(135deg, #000000 0%, #424242 100%)',
    textColor: '#FFFFFF',
    shouldGenerateStyle: false,
  },
}

/**
 * 用户标签
 */
export const USER_TAG_LABELS: UserTagLabelsType = {
  ...SCRIPTS_USER_TAG_LABELS,
  ...FEEDBACK_USER_TAG_LABELS,
  ...BASE_USER_TAG_LABELS,
}

/**
 * 用户标签样式
 */
export function getUserBadgeStyles(): string {
  return `display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0 5px;
    border-radius: 10px;
    white-space: nowrap !important;
    font-size: 11px !important;
    font-weight: 400;`
}
